package top.lucas9.wechat.push.entity;

import lombok.Data;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import top.lucas9.wechat.push.util.DateUtil;

import java.time.LocalDate;
import java.util.List;

/**
 *
 * @author lucas9
 * @date 2022/11/29 20:58
 */
@Data
public class WeatherDayResult extends WeatherResult {
    public static final String SUCCESS_CODE = "200";
    /**
     * 响应码
     */
    private String code;
    /**
     * 天气
     */
    private List<Daily> daily;
    /**
     * 天气页面
     */
    private String fxLink;

    public Daily getTodayWeather() {
        Assert.isTrue(!CollectionUtils.isEmpty(daily), "查询天气信息错误,请联系管理员");
        Assert.isTrue(DateUtil.isSameDay(daily.get(0).fxDate, LocalDate.now()), "未获取到当日天气,请重试");
        return daily.get(0);
    }

    public static class Daily {
        /**
         * 预报日期
         */
        private LocalDate fxDate;
        /**
         * 最高气温
         */
        private String tempMax;
        /**
         * 最低气温
         */
        private String tempMin;
        /**
         * 白天天气状况
         */
        private String textDay;
        /**
         * 夜间天气状况
         */
        private String textNight;
    }
}
